import { reqPostSearchListData } from '@/api';

const state = {
  goodsInfo: {}
};
const actions = {
  // 获取搜索的商品信息
  async reqPostSearchListDataActions(context, params) {
    const result = await reqPostSearchListData(params);
    if (result.code === 200) {
      context.commit('SAVE_SEARCH_GOODS_LIST', result.data);
    } else {
      console.log(result.message);
    }
  }
};
const mutations = {
  // 存储获取的商品信息
  SAVE_SEARCH_GOODS_LIST(state, goodsInfo) {
    state.goodsInfo = goodsInfo;
  }
};
const getters = {
  attrsList(state) {
    return state.goodsInfo.attrsList;
  },
  goodsList() {
    return state.goodsInfo.goodsList;
  },
  trademarkList(state) {
    return state.goodsInfo.trademarkList;
  },
  total(state) {
    return state.goodsInfo.total;
  }
};
export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters
};
